package com.bluetrum.devicemanager.cmd.request;

import com.bluetrum.devicemanager.cmd.Request;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public final class LeAudioBisSelectRequest extends Request {

    private final int identifier;
    private final boolean connect;

    public LeAudioBisSelectRequest(int identifier, boolean connect) {
        super(COMMAND_LE_AUDIO_BIS_SELECT);
        this.identifier = identifier;
        this.connect = connect;
    }

    @Override
    public byte[] getPayload() {
        ByteBuffer bb = ByteBuffer.allocate(1 + 4) // Action + ID
                .order(ByteOrder.LITTLE_ENDIAN);
        bb.put((byte) (connect ? 1 : 0));
        bb.putInt(identifier);
        return bb.array();
    }
}
